/* extension of 49
 */

#include<stdio.h>

int main(void){
  int a,b,c,d,e;  //1 stands for go, 0 stands for not go.
  int temp;
  int n=0;

  for(a=1;a>=0;a--)  //exausation of all possibility
   for(b=1;b>=0;b--)
     for(c=1;c>=0;c--)
       for(d=1;d>=0;d--)
         for(e=1;e>=0;e--)   
	        if((a+b==2||a==0)&&d+e<2&&b+c<2&&c+d!=1&&(e+a+d==3||e==0)&&a+b+c+d+e!=0)
		    {
		    printf("One possible solution is: %s%s%s%s%s\n", a?"A ":"", b?"B ":"", c?"C ":"", d?"D ":"", e?"E ":"");
                  temp = a+b+c+d+e;
            if(temp>n)
		        n=temp;              
            }
  printf("The group can go to at most %d places.\n", n);
  return 0;
}
